package com.xxja.order.utils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

public class PageRequest {
    private final Long DEFAULT_PAGE = 1L;
    private final Long DEFAULT_SIZE = 10L;

    private long page;
    private long size;

    private final Page pageInstance = new Page();

    public long getPage() {
        return page;
    }

    public void setPage(long page) {
        this.page = page;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

    public Page setLimit() {
        if (this.page <= 1) {
            this.page = DEFAULT_PAGE;
        }
        this.pageInstance.setCurrent(this.page);
        if (this.size < 1) {
            this.size = DEFAULT_SIZE;
        } else {
            this.pageInstance.setSize(this.size);
        }

        return this.pageInstance;
    }
}
